package com.hudson.core.json;

import com.google.gson.*;

import java.lang.reflect.Type;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @Author: 渔小鲤
 * @DateTime: 2025/7/13 1:55
 **/

public class AtomicLongTypeAdapter implements JsonSerializer<AtomicLong>, JsonDeserializer<AtomicLong> {
    @Override
    public JsonElement serialize(AtomicLong src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.get());
    }

    @Override
    public AtomicLong deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        return new AtomicLong(json.getAsLong());
    }
}
